package com.wmeimob.fastboot.jiubei.controller;

import com.github.pagehelper.PageInfo;
import com.wmeimob.fastboot.core.context.PageContext;
import com.wmeimob.fastboot.jiubei.entity.ShopGoodsBrowseRecord;
import com.wmeimob.fastboot.jiubei.service.ShopGoodsBrowseRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjt
 * @version 1.0
 * @className ShopGoodsBrowseRecordController
 * @description 【商品浏览记录】控制器
 * @date Mon Sep 07 23:58:44 CST 2020
 **/
@RestController
@RequestMapping("shopGoodsBrowseRecord")
@Slf4j
public class ShopGoodsBrowseRecordController {

    @Resource
    private ShopGoodsBrowseRecordService shopGoodsBrowseRecordService;


    /**
     * 商品浏览记录分页查询
     *
     * @param shopGoodsBrowseRecord
     * @return
     */
    @GetMapping
    public PageInfo queryForShopGoodsBrowseRecord(ShopGoodsBrowseRecord shopGoodsBrowseRecord) {
        PageContext.startPage();
        return new PageInfo<ShopGoodsBrowseRecord>(shopGoodsBrowseRecordService.list(shopGoodsBrowseRecord));

    }

    /**
     * 商品浏览记录导出
     *
     * @param shopGoodsBrowseRecord
     * @return
     */
    @PostMapping("/export")
    public List<ShopGoodsBrowseRecord> queryForShopGoodsBrowseRecordExport(@RequestBody ShopGoodsBrowseRecord shopGoodsBrowseRecord) {
        return shopGoodsBrowseRecordService.list(shopGoodsBrowseRecord);
    }


    /**
     * 商品浏览记录查询-<通过id查询>
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopGoodsBrowseRecord queryForShopGoodsBrowseRecordById(@PathVariable("id") Object id) {
        return shopGoodsBrowseRecordService.queryShopGoodsBrowseRecordById(id);
    }


    /**
     * 商品浏览记录添加
     *
     * @param shopGoodsBrowseRecord
     * @return
     */
    @PostMapping
    public void insertForShopGoodsBrowseRecord(@RequestBody ShopGoodsBrowseRecord shopGoodsBrowseRecord) {
        shopGoodsBrowseRecordService.addShopGoodsBrowseRecord(shopGoodsBrowseRecord);
    }


    /**
     * 商品浏览记录修改
     *
     * @param shopGoodsBrowseRecord
     * @return
     */
    @PutMapping
    public void updateForShopGoodsBrowseRecord(@RequestBody ShopGoodsBrowseRecord shopGoodsBrowseRecord) {
        shopGoodsBrowseRecordService.modifyShopGoodsBrowseRecord(shopGoodsBrowseRecord);
    }

    /**
     * 商品浏览记录删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public void removeForShopGoodsBrowseRecord(@PathVariable("id") Long id) {
        shopGoodsBrowseRecordService.removeShopGoodsBrowseRecord(id);
    }
}
